package cn.imnaer.service.persistence.model;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/5/27.
 */
public class FriendRequest {
    public final static Integer MAX_COUNT = 3;

    private String friendRequestId;
    private String sendUserId;
    private String sendUserName;
    private String acceptUserId;
    private String acceptUserName;
    /**
     * @see cn.imnaer.service.rpc.enums.EnumFriendRequestStatus
     */
    private String status;
    private Long createTime;
    /**
     * 接收人是否有未读消息
     */
    private Boolean isUnReadForAcceptUser = false;
    /**
     * 发送人是否有未读消息
     */
    private Boolean isUnReadForSendUser = false;
    private List<TemporarySession> session = new ArrayList<>();

    public String getFriendRequestId() {
        return friendRequestId;
    }

    public void setFriendRequestId(String friendRequestId) {
        this.friendRequestId = friendRequestId;
    }

    public String getSendUserId() {
        return sendUserId;
    }

    public void setSendUserId(String sendUserId) {
        this.sendUserId = sendUserId;
    }

    public String getAcceptUserId() {
        return acceptUserId;
    }

    public void setAcceptUserId(String acceptUserId) {
        this.acceptUserId = acceptUserId;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public List<TemporarySession> getSession() {
        return session;
    }

    public void setSession(List<TemporarySession> session) {
        this.session = session;
    }

    public Boolean getIsUnReadForAcceptUser() {
        return isUnReadForAcceptUser;
    }

    public void setIsUnReadForAcceptUser(Boolean isUnReadForAcceptUser) {
        this.isUnReadForAcceptUser = isUnReadForAcceptUser;
    }

    public Boolean getIsUnReadForSendUser() {
        return isUnReadForSendUser;
    }

    public void setIsUnReadForSendUser(Boolean isUnReadForSendUser) {
        this.isUnReadForSendUser = isUnReadForSendUser;
    }

    public String getSendUserName() {
        return sendUserName;
    }

    public void setSendUserName(String sendUserName) {
        this.sendUserName = sendUserName;
    }

    public String getAcceptUserName() {
        return acceptUserName;
    }

    public void setAcceptUserName(String acceptUserName) {
        this.acceptUserName = acceptUserName;
    }


    public FriendRequest sendSession(TemporarySession session) {
        if(this.getSession().size() == MAX_COUNT) {
            this.getSession().remove(0);
        }
        this.getSession().add(session);
        return this;
    }
}
